import axios from './axios.js';

export default {
    namespaced:true,
    state: {
        username: ''
    },
    actions:{
		//实名认证
		
        /**
         * 上传身份证到文件服务器
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async addFileApi({commit, state}, params) {
            try {
                let {data} = await axios.post('/api/account/user_certification/add_file',params);
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
        /**
         * 获取认证结果回调
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async callbackApi({commit, state}, params) {
            try {
                let {data} = await axios.delete('/api/account/user_certification/callback',{params});
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
        /**
         * 删除已上传的身份证图片
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async delFileApi({commit, state}, params) {
            try {
				console.log(params,'params');
                let {data} = await axios.delete('/api/account/user_certification/delete_file',{params});
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
        /**
         * 新增E签宝账号记录
         * @param commit
         * @param state
         * @param params 请求参数
         * @return {Promise<*[e, data]>} e错误信息，data数据
         */
        async insertsApi({commit, state}, params) {
            try {
                let {data} = await axios.post('/api/account/user_certification/insert',params);
                return [null, data]
            } catch (e) {
                return [e, null]
            }
        },
		/**
		 * 查询一条E签宝认证信息
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async queryEqbApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/account/user_certification/query_eqb/${params.userId}`,{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询一条数据库认证信息
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async queryApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/account/user_certification/query/${params.user_id}`,{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询查询个人所有印章
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async sealsApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/account/user_certification/seals/${params.userId}`,{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 识别身份证，人脸在第一张，国徽在第二张
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async userCardApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/user_certification/upload_card',params);
		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * E签宝手机号验证码校验
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async checkCodeApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/account/user_certification/check/${params.flow_id}/${params.code}`);
		        
				return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		
		//律师认证
		/**
		 * 获取认证结果回调
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async callBackApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/lawyer_certification/callback',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 新增E签宝律师账号记录
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async insertLawyerApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/lawyer_certification/insert',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询一条认证信息
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async queryLawyerApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/account/lawyer_certification/query/{params.userId}`,{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询律师用户所有印章
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async sealsLawyerApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get(`/api/account/lawyer_certification/seals/{params.userId}`,{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 新增律师认证审核
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async insertApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/user_lawyer_history/insert',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 新增律师认证审核
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async updateApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/user_lawyer_history/update',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 查询律师相关信息，如从业年限，擅长领域等
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async getUpdateApi({commit, state}, params) {
		    try {
		        let {data} = await axios.get('/api/account/lawyer_certification/update',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 编辑律师相关信息，如从业年限，擅长领域等
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async editUpdateApi({commit, state}, params) {
		    try {
		        let {data} = await axios.put('/api/account/lawyer_certification/update',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 识别身份证
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async uploadCardApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/lawyer_certification/upload_card',{params});
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 识别营业执照
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async uploadNumberApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/enterprise_certification/upload_number',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
		/**
		 * 新增E签宝企业账号记录,同时企业号实名认证
		 * @param commit
		 * @param state
		 * @param params 请求参数
		 * @return {Promise<*[e, data]>} e错误信息，data数据
		 */
		async insertNumberApi({commit, state}, params) {
		    try {
		        let {data} = await axios.post('/api/account/enterprise_certification/insert',params);
		        return [null, data]
		    } catch (e) {
		        return [e, null]
		    }
		},
	}
}